package com.uh.microservice.core.controller;

import com.uh.calculation.service.CalculationService;
import com.uh.microservice.core.service.PublicService;
import com.uh.summary.test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
 * 公用Controller
 * Created by fll on 2017/17.
 */
@RestController
@RequestMapping("/public")
public class PublicController extends BaseSupport {

    @Autowired
    private PublicService publicService;
    @Autowired
    private CalculationService calculationService;

    @RequestMapping("jsTest")
    public String jsTest(String id) {


        calculationService.test();
        return  "{}";

    }

    /**
     * 根据条件查询结果（不分页）
     * CODE ->sqlName DATA ->查询参数
     *
     * @return List
     */
    @RequestMapping("queryList")
    public String queryList() {
        return output(publicService.queryList(getInputParam()));
    }


    /**
     * 根据条件查询结果（分页）
     *
     * @return Map
     */
    @RequestMapping("/queryPage/{sqlName}")
    public String queryPage(@PathVariable String sqlName) {
        return output(publicService.queryPage(sqlName, getInputParam()));
    }


    /**
     * 基础操作（增删改）
     *
     * @return Map
     */
    @RequestMapping("/execute")
    public String execute() {
        return output(publicService.execute(getInputParam()));
    }


    /**
     * 根据ID获取记录
     *
     * @return Map
     */
    @RequestMapping("/queryById")
    public String queryById() {
        return output(publicService.getById(getInputParam()));
    }

    /**
     * 根据条件查询结果（成树）
     * CODE ->sqlName DATA ->查询参数
     *
     * @return List
     */
    @RequestMapping("/queryTree")
    public String queryTree() {
        return output(publicService.queryTree(getInputParam()));
    }


}